package com.wang.lottery.domain.award.service.goods.impl;

import com.wang.lottery.common.Constants;
import com.wang.lottery.domain.award.model.req.GoodsReq;
import com.wang.lottery.domain.award.model.res.DistributionRes;
import com.wang.lottery.domain.award.service.goods.DistributionBase;
import com.wang.lottery.domain.award.service.goods.IDistributionGoods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author wjh
 * @create 2023-11-03 18:40
 * 兑换码类商品
 */
@Service
@Slf4j
public class RedeemCodeGoods extends DistributionBase implements IDistributionGoods {
    /**
     * 奖品配送接口，奖品类型（1:文字描述、2:兑换码、3:优惠券、4:实物奖品）
     *
     * @param req 物品信息
     * @return 配送结果
     */
    @Override
    public DistributionRes doDistribution(GoodsReq req) {
        super.updateUserAwardState(req.getUId(),req.getOrderId(),req.getAwardId(), Constants.AwardState.SUCCESS.getCode(), Constants.AwardState.SUCCESS.getInfo());
        log.info("模拟兑换码类商品发放接口 uId：{} awardContent：{}", req.getUId(), req.getAwardContent());
        return new DistributionRes(req.getUId(), Constants.AwardState.SUCCESS.getCode(),Constants.AwardState.SUCCESS.getInfo());
    }

    /**
     * 获取奖品类型code
     *
     * @return 奖品类型code
     */
    @Override
    public Integer getDistributionGoodsName() {
        return Constants.AwardType.RedeemCodeGoods.getCode();
    }
}
